package com.example.demo.service;

import com.example.demo.entity.Huiyuan;
import com.example.demo.mapper.HuiyuanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.websocket.server.PathParam;
import java.util.ArrayList;
import java.util.List;

@Service
public class HuiyuanService {
    @Autowired
    HuiyuanMapper huiyuanMapper;

    public List<Huiyuan> getallgrade() {
        return huiyuanMapper.getallgrade();
    }

    public String insertgrade(Huiyuan huiyuan) {
        huiyuanMapper.insertgrade(huiyuan);
        return "新增成功";
    }

    public String deletegrade(int id) {
        huiyuanMapper.deletegrade(id);
        return "删除成功";
    }

    public String upgrade(Huiyuan huiyuan) {
        huiyuanMapper.upgrade(huiyuan);
        return "更新成功";
    }

    //获取全部图片分页
    public List<Huiyuan> getqbfenye(int currentpage, int pagesize) {
        int temp = 0;
        int i = (temp + currentpage - 1) * pagesize;
        return huiyuanMapper.getpicfenye(i, pagesize);
    }

    public List<Huiyuan> getallgrade1(String name) {
        return huiyuanMapper.mohu1(name);
    }

    public List<Huiyuan> getallgrade2(String name) {
        return huiyuanMapper.mohu2(name);
    }

    //获取全部图片分页
    public List<Huiyuan> mohu3(String name, String sex, String ab, String address, String phone, String memo, int i, int pagesize) {
        int temp = 0;
        int ii = (temp + i - 1) * pagesize;
        System.out.println("ii" + ii);
        List<Huiyuan> huiyuan = new ArrayList<>();
        if (memo.isEmpty() || memo == null) {


            huiyuan = huiyuanMapper.mohu3ps(name, sex, ab, address, phone, memo, ii, pagesize);
        } else {

            huiyuan = huiyuanMapper.mohu3(name, sex, ab, address, phone, memo, ii, pagesize);

        }

        return huiyuan;
    }
    public List<Huiyuan> mohuid(Integer id ,int i , int pagesize){
       return huiyuanMapper.mohuid( id, i , pagesize);
    }

}
